<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ChaoPai购物车</title>

</head>
<body>
<table border="1px">

    <tr>
        <td>
            <font  align="right">
                 【购物车】总金额：
                <%
                    Double ans = 0.0;
                    for(int i = 1; i <= 3 ; i++) {
                        if(session.getAttribute("goods" + i) != null){
                            Double price = Double.valueOf(session.getAttribute("price" + i).toString());
                            Double sum = Double.valueOf(session.getAttribute("goods" + i).toString());
                            ans += price * sum;
                        }
                    }
                    out.print(ans);
                %>
            </font>
        </td>
    </tr>


    <%
        if(session.getAttribute("goods1") != null){
    %>
        <tr>
            <td>
                <div class = "price">
                    <h3> 衣服</h3>
                    单价：<%=session.getAttribute("price1")%><br>
                    数量：<%=session.getAttribute("goods1") == null ? 0 : session.getAttribute("goods1")%><br>
                    总金额：
                    <%
                        Double price2 = Double.valueOf(session.getAttribute("price1").toString());
                        Double sum2 = Double.valueOf(session.getAttribute("goods1").toString());
                        out.print((price2 * sum2));
                    %>
                </div>
            </td>
        </tr>
    <%
        }


        if(session.getAttribute("goods2") != null){
    %>
            <tr>
                <td>
                    <div class = "price">
                        <h3> 帽子</h3>
                        单价：<%=session.getAttribute("price2")%><br>
                        数量：<%=session.getAttribute("goods2") == null ? 0 : session.getAttribute("goods2")%><br>
                        总金额：
                        <%
                            Double price2 = Double.valueOf(session.getAttribute("price2").toString());
                            Double sum2 = Double.valueOf(session.getAttribute("goods2").toString());
                            out.print((price2 * sum2));
                        %>
                    </div>
                </td>
            </tr>
    <%
        }


        if(session.getAttribute("goods3") != null){
            %>
            <tr>
                <td>
                    <div class = "price">
                        <h3> 鞋子</h3>
                        单价：<%=session.getAttribute("price3")%><br>
                        数量：<%=session.getAttribute("goods3") == null ? 0 : session.getAttribute("goods3")%><br>
                        总金额：
                        <%
                            Double price2 = Double.valueOf(session.getAttribute("price3").toString());
                            Double sum2 = Double.valueOf(session.getAttribute("goods3").toString());
                            out.print((price2 * sum2));
                        %>
                    </div>
                </td>
            </tr>
    <%
        }
    %>
    <tr>
        <td><a href="shop.jsp">返回购物页面</a></td>
    </tr>
</table>

</body>
</html>
